// 头部
(function(){
    $(".shenglu").on("click", function () {
        $(this).addClass("icon-hidden").siblings().removeClass("icon-hidden");
        $(".top-nav").css("display", "block");
        console.log("...")
    })
    $(".close").on("click", function () {
        $(this).addClass("icon-hidden").siblings().removeClass("icon-hidden")
        console.log("x");
        $(".top-nav").css("display", "none");
    })
})();

// 商品展示部分
(function(){
    $.ajax({
        url: "../php/bailian.php",
        dataType: "json",
        error: function () {
            alert('请求失败')
        },
        success: function (asd) {
            var html = ""
            var html2 = ""
            var html3 = ""
            for (var i = 0; i < 27; i++) {
                html +=
                    "<li class='mysh-cp-ul-li'><div class='mysh-cp-ul-li-area'><div class='mysh-cp-ul-li-area-IMG'><a href='../html-wyh/detail.html'><img src=" +
                    asd[i].img_url + " alt=''></a></div><div class='mysh-cp-ul-li-area-title'>" + asd[i]
                        .text + "</div><div class='mysh-cp-ul-li-area-zhekou'>" + asd[i].zhekou +
                    "</div><div class='mysh-cp-ul-li-area-price'><div class='mysh-cp-ul-li-area-price-price'>￥" +
                    asd[i].price +
                    "</div><div class='mysh-cp-ul-li-area-jiahao'><div class='jiahao iconfont iconwei-'></div></div></div></div></li>"
            }
            $('.mysh-cp-ul').eq(0).html(html)
            for (var i = 27; i < 57; i++) {
                html2 +=
                    "<li class='mysh-cp-ul-li'><div class='mysh-cp-ul-li-area'><div class='mysh-cp-ul-li-area-IMG'><a href='../html-wyh/detail.html'><img src=" +
                    asd[i].img_url + " alt=''></a></div><div class='mysh-cp-ul-li-area-title'>" + asd[i]
                        .text + "</div><div class='mysh-cp-ul-li-area-zhekou'>" + asd[i].zhekou +
                    "</div><div class='mysh-cp-ul-li-area-price'><div class='mysh-cp-ul-li-area-price-price'>￥" +
                    asd[i].price +
                    "</div><div class='mysh-cp-ul-li-area-jiahao'><div class='jiahao iconfont iconwei-'></div></div></div></div></li>"
            }
            $('.mysh-cp-ul').eq(1).html(html2)
            for (var i = 57; i < 72; i++) {
                html3 +=
                    "<li class='mysh-cp-ul-li'><div class='mysh-cp-ul-li-area'><div class='mysh-cp-ul-li-area-IMG'><a href='../html-wyh/detail.html'><img src=" +
                    asd[i].img_url + " alt=''></a></div><div class='mysh-cp-ul-li-area-title'>" + asd[i]
                        .text + "</div><div class='mysh-cp-ul-li-area-zhekou'>" + asd[i].zhekou +
                    "</div><div class='mysh-cp-ul-li-area-price'><div class='mysh-cp-ul-li-area-price-price'>￥" +
                    asd[i].price +
                    "</div><div class='mysh-cp-ul-li-area-jiahao'><div class='jiahao iconfont iconwei-'></div></div></div></div></li>"
            }
            $('.mysh-cp-ul').eq(2).html(html3)
        }
    })
})();
//回到顶部
(function(){
    $(".hddb-a").click(function () {
        var top = $('html,body').scrollTop()
        var top_s = top / 100
        var timer = setInterval(function () {
            top = top - top_s
            if (top <= 0) {
                clearInterval(timer)
            }
            $('html,body').scrollTop(top)
        }, 10)
    })
})();